<?php
namespace app\admin\controller;

use think\Config;
use \think\Controller;
use think\Request;

class Auth extends Controller
{
    protected $data;
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
    }

    public function lists()
    {
        return $this->fetch();
    }

    public function add()
    {
        $data['field'] = 'id,auth_name';
        $data['where'] = array('is_tyle'=>'0');
        $data['data'] = model('Auth')->lists($data);
        $this->assign('data',$data['data']);
        return $this->fetch();
    }

    public function edit()
    {
        $data['field'] = 'id,auth_name,auth_rules,is_tyle,parent_id';
        $data['data'] = model('Auth')->lists($data);
        foreach ($data['data'] as $key=>$value){
            if($value['id'] == $this->request->param('id')){
                $data['oneData'] = $value;
            }
            if($value['is_tyle'] == '0'){
                $data['lists'][] = $value;
            }
            unset($data['data'][$key]);
        }
        $this->assign('data_lists',$data['lists']);
        $this->assign('data_oneData',$data['oneData']);
        return $this->fetch();
    }
}
